<script setup>
import {ref} from 'vue'

const inputUsername = ref('')
const emit = defineEmits(['submit-username'])
const handleSubmit = () => {
  emit('submit-username', inputUsername.value)
}
</script>

<template>

  <el-form @submit.prevent="handleSubmit" class="login-container" label-position="left" label-width="0px">
    <h1 class="login_title">输入名字</h1>
    <el-form-item>
      <el-input v-model="inputUsername" type="text" placeholder="用户名" autocomplete="off" :maxlength="20"/>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" round native-type="submit" class="submit-button">开始聊天</el-button>
    </el-form-item>
  </el-form>
</template>

<style scoped>
.login-container {
  border-radius: 15px;
  background-clip: padding-box;
  margin: 90px auto;
  width: 350px;
  padding: 35px 35px 15px 35px;
  background: #fff;
  border: 1px solid #eaeaea;
  box-shadow: 0 0 25px #cac6c6;
}

.login_title {
  margin: 0px auto 40px auto;
  text-align: center;
  color: #505458;
}
.submit-button {
  display: block;
  margin: 0 auto; /* 水平居中 */
}
</style>